﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DFT.DB;
using DFT.Infos;

namespace DFT.AJAX
{
    public partial class GetAllRelatuionsUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            if (DBManager.GetAllRelationsUser(((UserInfo)Session["userInfo"]).UserId, ref dt))
            {
                Response.ContentType = "text/xml";
                Response.Write("<?xml version='1.0' encoding='utf-8'?>");
                Response.Write("<Relations>");
                foreach (DataRow dr in dt.Rows)
                {
                    Response.Write("<Relation>");
                    Response.Write("<Id>" + dr["relationId"].ToString() + "</Id>");
                    Response.Write("<TreeId>" + dr["userId"].ToString() + "</TreeId>");
                    Response.Write("<Name>" + dr["fullName"].ToString() + "</Name>");
                    Response.Write("</Relation>");
                }
                Response.Write("</Relations>");
                Response.End();
            }
        }
    }
}